{% comment %} ----------------------------------------------------------------*\
 |  bookmarks.html                                                            |
 |                                                                            |
 |  Copyright (c) 2009-2010, Code A La Mode, original authors.                |
 |                                                                            |
 |      This file is part of imi-imi.                                         |
 |                                                                            |
 |      imi-imi is free software; you can redistribute it and/or modify       |
 |      it under the terms of the GNU General Public License as published by  |
 |      the Free Software Foundation, either version 3 of the License, or     |
 |      (at your option) any later version.                                   |
 |                                                                            |
 |      imi-imi is distributed in the hope that it will be useful,            |
 |      but WITHOUT ANY WARRANTY; without even the implied warranty of        |
 |      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         |
 |      GNU General Public License for more details.                          |
 |                                                                            |
 |      You should have received a copy of the GNU General Public License     |
 |      along with imi-imi.  If not, see <http://www.gnu.org/licenses/>.      |
\*------------------------------------------------------------- {% endcomment %}


{% for bookmark in bookmarks %}
    <li class="bookmark" {% if snippet %}style="display: none;"{% endif %}>
        <div class="speech_balloon">
            <h3>
                <a href="{{ bookmark.url }}"
                   title="{{ bookmark.url|beautify_url }}"
                   target="_blank"
                   rel="nofollow">{{ bookmark|beautify_title }}</a>
            </h3>

            <span class="saved_by">
                Saved by
                {% if not bookmark.popularity|add:"-1" %}
                    <a href="/users/{{ bookmark.users.0.email }}">{{ bookmark.users.0.nickname }}</a>
                {% else %}
                    <span id="others_short_{{ bookmark.key }}">
                        <a href="/users/{{ bookmark.users.0.email }}">{{ bookmark.users.0.nickname }}</a>
                        and {{ bookmark.popularity|add:"-1" }}
                        other{{ bookmark.popularity|add:"-1"|pluralize }}
                        <a href="#"
                           onclick="$('#others_short_{{ bookmark.key }}').hide();
                                    $('#others_long_{{ bookmark.key }}').show();
                                    return false;">&rarr;</a>
                    </span>
                    <span id="others_long_{{ bookmark.key }}" style="display: none">
                        {% for user in bookmark.users %}
                            {% if forloop.last %}and{% endif %}
                            <a href="/users/{{ user.email }}">{{ user.nickname }}</a>{% if not forloop.last %},{% endif %}
                        {% endfor %}
                        <a href="#"
                           onclick="$('#others_long_{{ bookmark.key }}').hide();
                                    $('#others_short_{{ bookmark.key }}').show();
                                    return false;">&larr;</a>
                    </span>
                    updated
                {% endif %}
                {{ bookmark.updated|beautify_datetime }}
            </span>

            {% if not bookmark.words and bookmark|is_image %}
                <a href="{{ bookmark.url }}" target="_blank">
                    <img src="{{ bookmark.url }}"
                         class="bookmark"
                         alt="{{ bookmark|beautify_title }}"
                         rel="#overlay_{{ bookmark.key }}" />
                </a>
                <div id="overlay_{{ bookmark.key }}" class="overlay">
                    <img src="{{ bookmark.url }}"
                         alt="{{ bookmark|beautify_title }}" />
                </div>
            {% endif %}

            {% if bookmark|is_audio %}
                <embed type="application/x-shockwave-flash"
                       src="http://www.google.com/reader/ui/3247397568-audio-player.swf?audioUrl={{ bookmark.url }}"
                       width="460" height="27"
                       allowscriptaccess="never" quality="best" wmode="window" flashvars="playerMode=embedded"
                       bgcolor="#FFFFFF" />
            {% endif %}

            {% if bookmark|is_youtube_video %}
                <script type="text/javascript" src="swfobject.js"></script>
                <div id="{{ bookmark.key.id }}">
                    <p>
                        You need Flash player 8+ installed and JavaScript
                        enabled to view this video.
                    </p>
                </div>
                <script type="text/javascript">
                    var params = {allowScriptAccess: "always"};
                    var atts = {id: "myytplayer"};
                    swfobject.embedSWF("{{ bookmark|make_youtube_url }}",
                                       "{{ bookmark.key.id }}",
                                       "460", "385", "8", null, null, params, atts);
                </script>
            {% endif %}

            {% if bookmark.words and not bookmark|is_audio and not bookmark|is_youtube_video %}
                <ul class="tag_cloud">
                    {% for word in bookmark.words %}
                        <li class="tag">
                            <a href="/search?query={{ word }}"
                               class="{{ bookmark|style_tag:word }}"
                               rel="nofollow">{{ word }}</a>
                        </li>
                    {% endfor %}
                </ul>
            {% endif %}

            {% if not bookmark.words and not bookmark|is_image and not bookmark|is_audio %}
                <p>
                    We couldn&rsquo;t auto-tag
                    <a href="{{ bookmark.url }}" target="_blank">{{ bookmark.url }}</a>.
                    The URL may be incorrect, the server may be down, or the
                    URL may not point to text, HTML, an image, an MP3, or a
                    YouTube video.
                </p>
            {% endif %}
        </div>

        <div class="speech_balloon_tail">
            <img src="/static-files/images/speech_balloon_tail.png" alt="" />
        </div>

        <div class="gravatar">
            <a href="/users/{{ bookmark.users.0.email }}">
                <img src="{{ bookmark.users.0|user_to_gravatar }}"
                     alt="{{ bookmark.users.0.nickname }}"
                     title="{{ bookmark.users.0.nickname }}" />
            </a>
        </div>

    </li>
{% endfor %}

{% include "more.html" %}
